import 'package:card_swiper/card_swiper.dart';
import 'package:flutter/material.dart';
import 'package:flutter_changdian_football/pages/clubs/clubs_controller.dart';
import 'package:flutter_changdian_football/pages/clubs/widget/club_empty.dart';
import 'package:flutter_changdian_football/pages/mine/user_store.dart';
import 'package:flutter_changdian_football/routers/app_routes.dart';
import 'package:flutter_changdian_football/utils/custom_constant.dart';
import 'package:flutter_changdian_football/utils/custom_toast.dart';
import 'package:flutter_changdian_football/widget/default_page/custom_empty.dart';
import 'package:flutter_changdian_football/widget/dialog/input_dialog.dart';
import 'package:flutter_changdian_football/widget/dialog/switch_club_dialog.dart';
import 'package:flutter_changdian_football/widget/extended_image_slide_widget.dart';
import 'package:flutter_changdian_football/widget/load_state/load_state_layout.dart';
import 'package:flutter_changdian_football/widget/screenutil/custom_screenutil.dart';
import 'package:flutter_changdian_football/widget/sheet/share_icon_sheet.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';
import 'package:marquee/marquee.dart';

/// 俱乐部
class ClubsPage extends StatefulWidget {
  const ClubsPage({super.key});

  @override
  State<ClubsPage> createState() => _ClubsPageState();
}

class _ClubsPageState extends State<ClubsPage> with AutomaticKeepAliveClientMixin {

  @override
  bool get wantKeepAlive => true;

  @override
  Widget build(BuildContext context) {
    super.build(context);
    
    return Scaffold(
      backgroundColor: const Color(0xffF8FAF9),
      body: GetBuilder<UserStore>(
        builder: (userStore) {
          if (userStore.isLogin == false) {
            return const ClubEmpty();
          }
          return GetBuilder<ClubsController>(
            init: ClubsController(),
            builder: (clubsController) {
              return LoadStateLayout(
                state: clubsController.state,
                empty: const ClubEmpty(),
                success: Stack(
                  children: [
                    Column(
                      children: [
                        Expanded(
                          child: RefreshIndicator(
                            color: const Color(0xff499360),
                            onRefresh: () async {
                              await Future.delayed(const Duration(milliseconds: 1000));
                              EasyLoading.show();
                              clubsController.initData();
                            },
                            child: SingleChildScrollView(
                              controller: clubsController.scrollController,
                              padding: EdgeInsets.only(bottom: 30.w),
                              child: Column(
                                children: [
                                  Stack(
                                    children: [
                                      _clubInfoWidget(clubsController),

                                      if (clubsController.clubCenterModel?.bulletin != null) ...[
                                        Positioned(
                                          bottom: 0.w,
                                          child: Container(
                                            height: 40.w,
                                            width: MediaQuery.of(context).size.width,
                                            color: const Color(0xffF09D20),
                                            child: Row(
                                              children: [
                                                Container(
                                                  width: 40.w,
                                                  height: 40.w,
                                                  decoration: BoxDecoration(
                                                    color: const Color(0xffE7951B),
                                                    borderRadius: BorderRadius.only(
                                                      topLeft: Radius.circular(8.r),
                                                      bottomLeft: Radius.circular(8.r),
                                                    )
                                                  ),
                                                  padding: EdgeInsets.all(10.w),
                                                  child: Image.asset('assets/images/fpgg.png', color: Colors.white,),
                                                ),
                                          
                                                SizedBox(width: 9.w,),
                                          
                                                Expanded(
                                                  child: Marquee(
                                                    text: '${clubsController.clubCenterModel?.bulletin == null ? '该俱乐部暂无公告      ' : '${clubsController.clubCenterModel?.bulletin}'}      ',
                                                    style: TextStyle(fontSize: 12.sp, fontWeight: FontWeight.w400, color: Colors.white),
                                                  )
                                                  // child: Text('${clubsController.clubCenterModel?.bulletin}', style: TextStyle(fontSize: 12.sp, fontWeight: FontWeight.w400, color: Colors.white), maxLines: 1, overflow: TextOverflow.ellipsis,),
                                                )
                                              ],
                                            ),
                                          )
                                        )
                                      ]
                                    ],
                                  ),
                                        
                                  SizedBox(height: 10.w,),
                                        
                                  _ribbonWidget(clubsController),
                                        
                                  SizedBox(height: 10.w,),
                          
                                  if ((clubsController.clubCenterModel?.clubMatchInfoVOS?.length ?? 0) > 0) ...[
                                    _otherTeamWidget(clubsController),
                                  ] else if (clubsController.clubCenterModel?.userRoleCode == CustomConstant.CLUB_ROLE_CHAIRMAN || clubsController.clubCenterModel?.userRoleCode == CustomConstant.CLUB_ROLE_ADMINISTRATORS) ...[
                                    _launchingTheContest(clubsController),
                                  ] else ...[
                                    _otherTeamEmpty()
                                  ],
                                  
                                  SizedBox(height: 10.w,),
                                        
                                  _trendsWidget(clubsController)
                                ],
                              ),
                            ),
                          ),
                        )
                      ],
                    ),
              
              
                    Positioned(
                      top: 0,
                      left: 0,
                      right: 0,
                      child: PreferredSize(
                        preferredSize: const Size.fromHeight(kToolbarHeight), // 设置 AppBar 的高度为 0
                        child: AppBar(
                          elevation: 0, 
                          backgroundColor: const Color(0xffF8FAF9).withAlpha(clubsController.titleAlpha),
                          title: Text(clubsController.clubCenterModel?.clubName ?? '', style: TextStyle(fontSize: 16.sp, color: const Color(0xff333333).withAlpha(clubsController.titleAlpha)),),
                          centerTitle: true,
                          actions: [
                            Stack(
                              children: [
                                Container(
                                  alignment: Alignment.centerRight,
                                  margin: EdgeInsets.only(right: 17.w),
                                  child: GestureDetector(
                                    behavior: HitTestBehavior.translucent,
                                    onTap: () {
                                      _showMenu(clubsController);
                                    },
                                    child: SizedBox(
                                      width: 30.w,
                                      height: 30.w,
                                      child: Image.asset('assets/images/ddd.png', fit: BoxFit.fill, color: clubsController.titleAlpha > 100 ? const Color(0xff333333) : Colors.white,),
                                    ),
                                  ),
                                ),

                                if (int.parse('${clubsController.clubCenterModel?.checkMessageNum ?? 0}') > 0) ...[
                                  Positioned(
                                    top: 10.w,
                                    right: 10.w,
                                    child: Container(
                                      width: 15.w,
                                      height: 15.w,
                                      decoration: BoxDecoration(
                                        color: const Color(0xffF4333C),
                                        borderRadius: BorderRadius.circular(15.r)
                                      ),
                                      alignment: Alignment.center,
                                      child: Text('${int.parse('${clubsController.clubCenterModel?.checkMessageNum ?? 0}')}', style: TextStyle(fontSize: 9.sp, color: Colors.white),),
                                    )
                                  )
                                ]
                              ],
                            )
                          ],
                        ),
                      ),
                    )
                  ],
                ),
              );
            },
          );
        }
      )
    );
  }


  _showMenu(ClubsController clubsController) {
    showMenu(
      color: Colors.white, //弹出框的颜色
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.all(
          Radius.circular(6.r)
        )
      ), //给弹出框添加一个圆角形状
      elevation: 10,
      context: Get.context!,
      position: const RelativeRect.fromLTRB(100, 80, 0, 0),
      items: <PopupMenuEntry>[
        if (clubsController.clubCenterModel?.userRoleCode == 'CHAIRMAN' || clubsController.clubCenterModel?.userRoleCode == 'ADMINISTRATORS') ...[
          _popupMenuItem(text: '消息盒子', icon: 'assets/images/xxhz.png', checkMessageNum: int.parse('${clubsController.clubCenterModel?.checkMessageNum ?? 0}'), onTap: () {
            Get.toNamed(AppRoutes.clubNews, parameters: {
              'clubId': '${clubsController.clubCenterModel?.clubId}'
            });
          }),

          const PopupMenuDivider(),
        ],
        
        if (clubsController.clubCenterModel?.userRoleCode == 'CHAIRMAN' || clubsController.clubCenterModel?.userRoleCode == 'ADMINISTRATORS') ...[
          _popupMenuItem(text: '发布公告', icon: 'assets/images/fpgg.png', onTap: () {
            Get.toNamed(AppRoutes.announcement, parameters: {
              'clubId': '${clubsController.clubCenterModel?.clubId}'
            });
          }),

          const PopupMenuDivider(),
        ],
        
        _popupMenuItem(text: '切换俱乐部', icon: 'assets/images/qhjlb.png', onTap: () {
          SwitchClubDialog.show(
            Get.context!,
            createTap: () {
              Get.offNamed(AppRoutes.createClub);
            }
          );
        }),
        const PopupMenuDivider(), 

        if (clubsController.clubCenterModel?.userRoleCode == 'CHAIRMAN' || clubsController.clubCenterModel?.userRoleCode == 'ADMINISTRATORS') ...[
          _popupMenuItem(text: '发起比赛', icon: 'assets/images/fpgg.png', onTap: () {
            Get.toNamed(AppRoutes.createContest, parameters: {
              'regionCode': '${clubsController.clubCenterModel?.clubRegionCode}',
              'clubId': '${clubsController.clubCenterModel?.clubId}',
            });
          }),

          const PopupMenuDivider(),
        ],


        _popupMenuItem(text: '显示名设置', icon: 'assets/images/xsmsz.png', onTap: () {
          clubsController.displayName();
        }),
        const PopupMenuDivider(), 
        _popupMenuItem(text: '分享', icon: 'assets/images/fx.png', onTap: () {
          clubsController.getSharePage();
        }),
      ]
    );
  }

  _popupMenuItem({
    String icon = '',
    String text = '',
    Function? onTap,
    int checkMessageNum = 0
  }) {
    return PopupMenuItem(
      padding: const EdgeInsets.symmetric(horizontal: 10,),
      height: 24.w,
      child: SizedBox(
        width: 90.w,
        height: 15.w,
        child: Row(
          children: [
            Image.asset(icon),
            Padding(padding: EdgeInsets.only(left: 8.w)),
            Text(text, style: TextStyle(color: const Color(0xff333333), fontSize: 11.sp),),
            if (double.parse('$checkMessageNum') > 0) ...[
              SizedBox(width: 4.w,),
              Container(
                width: 15.w,
                height: 15.w,
                decoration: BoxDecoration(
                  color: const Color(0xffF4333C),
                  borderRadius: BorderRadius.circular(15.r)
                ),
                alignment: Alignment.center,
                child: Text('$checkMessageNum', style: TextStyle(fontSize: 9.sp, color: Colors.white),),
              )
            ]
          ],
        ),
      ),
      onTap: () {
        Future.delayed(const Duration(milliseconds: 100), (){
          onTap?.call();
        });
      },
    );
  }

  _topValAndBottomTxt({
    String val = '',
    String txt = ''
  }) {
    return Column(
      children: [
        SizedBox(
          child: Text(val, style: TextStyle(fontSize: 18.sp, fontWeight: FontWeight.w700, color: const Color(0xffEDFFF3)),),
        ),
        SizedBox(height: 6.w,),
        SizedBox(
          child: Text(txt, style: TextStyle(fontSize: 12.sp, fontWeight: FontWeight.w400, color:  const Color(0xffA0D6B1)),),
        )
      ],
    );
  }

  /// 俱乐部信息
  _clubInfoWidget(ClubsController clubsController) {
    return Container(
      width: double.infinity,
      height: clubsController.clubCenterModel?.bulletin != null && clubsController.clubCenterModel?.bulletin != '' ? 230.w : 200.w,
      // height: 230.w,
      color: const Color(0xff5c9164),
      padding: EdgeInsets.only(left: 22.w, right: 22.w, top: clubsController.clubCenterModel?.bulletin != null && clubsController.clubCenterModel?.bulletin != '' ? 0.w : 30.w),
      child: Row(
        children: [
          GestureDetector(
            behavior: HitTestBehavior.translucent,
            onTap: () {
              if (clubsController.clubCenterModel?.clubAvatar != null) {
                Get.to(
                  ExtendedImageSlideWidget(
                    url: "${clubsController.clubCenterModel?.clubAvatar ?? ''}",
                  ),
                  opaque: false
                );
              }
            },
            child: Container(
              width: 72.w,
              height: 72.w,
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(10.r)
              ),
              padding: EdgeInsets.all(1.w),
              child: ClipRRect(
                borderRadius: BorderRadius.circular(10.r),
                child: Image.network(clubsController.clubCenterModel?.clubAvatar ?? '', fit: BoxFit.fill,),
              ),
            ),
          ),

          SizedBox(width: 12.w,),

          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                SizedBox(
                  child: Text(clubsController.clubCenterModel?.clubName ?? '', style: TextStyle(color: Colors.white, fontWeight: FontWeight.w700, fontSize: 17.sp),),
                ),

                SizedBox(height: 12.w,),

                SizedBox(
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      _topValAndBottomTxt(txt: '比赛场次', val: '${clubsController.clubCenterModel?.matchCount ?? '0'}'),

                      _topValAndBottomTxt(txt: '球员数', val: '${clubsController.clubCenterModel?.playerNum ?? '0'}'),

                      _topValAndBottomTxt(txt: '活跃度', val: '${clubsController.clubCenterModel?.liveness ?? '0'}'),
                    ],
                  ),
                )
              ],
            ),
          )
        ],
      ),
    );
  }

  // 功能区
  _ribbonWidget(ClubsController clubsController) {
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(10.r)
      ),
      margin: EdgeInsets.symmetric(horizontal: 17.w),
      child: GridView.builder(
        gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
          crossAxisCount: 4,
          crossAxisSpacing: 9,
          mainAxisSpacing: 9,
          childAspectRatio: 0.9
        ),
        itemCount: clubsController.gnqList.length,
        physics: const NeverScrollableScrollPhysics(),
        shrinkWrap: true,
        padding: EdgeInsets.zero,
        itemBuilder: (BuildContext context, int index) {
          return GestureDetector(
            behavior: HitTestBehavior.translucent,
            onTap: () {
              if (index == 0) {
                /// 俱乐部信息
                Get.toNamed(AppRoutes.clubInfo, parameters: {
                  'clubId': '${clubsController.clubCenterModel?.clubId ?? ''}'
                });
              } else if (index == 1) {
                /// 财政
                Get.toNamed(AppRoutes.finances, parameters: {
                  'clubId': '${clubsController.clubCenterModel?.clubId ?? ''}'
                });
              } else if (index == 2) {
                /// 比赛记录
                // Get.toNamed(AppRoutes.createContest);
                Get.toNamed(AppRoutes.gameRecord);
              } else if (index == 3) {
                /// 球员
                Get.toNamed(AppRoutes.clubPlayers, parameters: {
                  'clubId': '${clubsController.clubCenterModel?.clubId ?? ''}'
                });
              }
            },
            child: Container(
              padding: EdgeInsets.symmetric(vertical: 15.w),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  SizedBox(
                    width: 32.w,
                    height: 32.w,
                    child: Image.asset(clubsController.gnqList[index]['icon']),
                  ),
          
                  SizedBox(height: 8.w,),

                  SizedBox(
                    child: Text(clubsController.gnqList[index]['name'], style: TextStyle(fontSize: 12.sp, color: const Color(0xff000000), fontWeight: FontWeight.w400),),
                  )
                ],
              ),
            ),
          );
        },
      ),
    );
  }

  // 暂无其他团队
  _otherTeamEmpty() {
    return Container(
      margin: EdgeInsets.symmetric(horizontal: 17.w,),
      width: double.infinity,
      height: 168.w,
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(12.r),
        boxShadow: const [
          BoxShadow(
            color: Color.fromRGBO(138, 211, 161, 0.2),
            offset: Offset(0, 4),
            blurRadius: 12,
            spreadRadius: 0,
          ),
        ],
      ),
      padding: EdgeInsets.symmetric(vertical: 15.w),
      child: Column(
        children: [
          SizedBox(
            width: 200.w,
            child: Image.asset('assets/images/pic01.png'),
          ),

          SizedBox(
            child: Text('暂无俱乐部比赛，等待俱乐部主席或管理员发起比赛', style: TextStyle(fontSize: 12.sp, color: const Color(0xff9E9E9E)),),
          )
        ],
      ),
    );
  }

  /// 发起比赛
  _launchingTheContest(ClubsController clubsController) {
    return Container(
      margin: EdgeInsets.symmetric(horizontal: 17.w,),
      width: double.infinity,
      height: 168.w,
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(12.r),
        boxShadow: const [
          BoxShadow(
            color: Color.fromRGBO(138, 211, 161, 0.2),
            offset: Offset(0, 4),
            blurRadius: 12,
            spreadRadius: 0,
          ),
        ],
      ),
      padding: EdgeInsets.symmetric(vertical: 15.w),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          SizedBox(
            width: 200.w,
            child: Image.asset('assets/images/pic01.png'),
          ),

          Container(
            margin: EdgeInsets.only(right: 29.w),
            child: GestureDetector(
              behavior: HitTestBehavior.translucent,
              onTap: () {
                Get.toNamed(AppRoutes.createContest, parameters: {
                  'regionCode': '${clubsController.clubCenterModel?.clubRegionCode}',
                  'clubId': '${clubsController.clubCenterModel?.clubId}',
                });
              },
              child: Container(
                decoration: BoxDecoration(
                  color: const Color(0xff499360),
                  borderRadius: BorderRadius.circular(24.r)
                ),
                padding: EdgeInsets.symmetric(vertical: 9.w, horizontal: 21.w),
                child: Text('发起比赛', style: TextStyle(fontSize: 12.sp, color: Colors.white, fontWeight: FontWeight.w500),),
              ),
            )
          )
        ],
      ),
    );
  }

  _otherTeamWidget(ClubsController clubsController) {
    return SizedBox(
      height: 168.w,
      child: Swiper(
        index: 0,
        loop: false,
        // viewportFraction: list.length == 1 ? 1.0 : 0.9,
        viewportFraction: 0.91,
        // scale: list.length == 1 ? 1.0 : 0.97,
        scale: 0.95,
        itemCount: clubsController.clubCenterModel?.clubMatchInfoVOS?.length ?? 0,
        itemBuilder: (context, index) {
          var item = clubsController.clubCenterModel?.clubMatchInfoVOS?[index];
    
          Color bgColor = const Color(0xff499360);
          String floatText = '快速报名';

          if (item?.isSignUp == true) {
            if (item?.isPay == true) {
              bgColor = const Color(0xffF4333C);
              if (item?.normalCancellation == true) {
                floatText = '取消报名';
              } else {
                floatText = '报水';
              }
            } else if (item?.isPay == false) {
              bgColor = const Color(0xffFF9100);
              floatText = '去缴费';
            } else {
              // 禁用报名
              bgColor = const Color(0xffCCCCCC);
            }
          }
          return Stack(
            clipBehavior: Clip.none,
            children: [
              Container(
                padding: EdgeInsets.only(right: 10.w),
                child: Container(
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(12.r),
                    color: Colors.white,
                  ),
                  padding: EdgeInsets.only(top: 18.w, left: 24.w),
                  child: Column(
                    children: [
                      _typeColumnIconTextWidget(text: clubsController.clubCenterModel?.clubMatchInfoVOS?[index].courtName ?? '', icon: 'assets/images/game_local.png'),

                      _typeColumnIconTextWidget(text: clubsController.clubCenterModel?.clubMatchInfoVOS?[index].matchTime ?? '', icon: 'assets/images/game_time.png'),

                      SizedBox(
                        child: Row(
                          children: [
                            _typeRowIconTextWidget(text: clubsController.clubCenterModel?.clubMatchInfoVOS?[index].matchRulesName ?? '', icon: 'assets/images/game_rule.png'),
                            SizedBox(width: 60.w,),
                            _typeRowIconTextWidget(text: (clubsController.clubCenterModel?.clubMatchInfoVOS?[index].isPunishment == 'true') ? '报水罚款' : '无报水惩罚', icon: 'assets/images/game_warning.png'),
                          ],
                        ),
                      ),

                      const Spacer(),

                      Container(
                        width: double.infinity,
                        height: 0.5.w,
                        color: const Color(0xffDDDDDD),
                      ),

                      Container(
                        padding: EdgeInsets.symmetric(vertical: 12.w),
                        child: Row(
                          children: [
                            SizedBox(
                              child: Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: [
                                  SizedBox(
                                    child: RichText(
                                      text: TextSpan(
                                        children: [
                                          TextSpan(
                                            text: '¥',
                                            style: TextStyle(fontSize: 12.sp, color: const Color(0xff499360), fontWeight: FontWeight.w700)
                                          ),
                                          TextSpan(
                                            text: clubsController.clubCenterModel?.clubMatchInfoVOS?[index].siteFees ?? '0',
                                            style: TextStyle(fontSize: 16.sp, color: const Color(0xff499360), fontWeight: FontWeight.w700)
                                          )
                                        ]
                                      )
                                    ),
                                  ),

                                  SizedBox(height: 2.w,),

                                  SizedBox(
                                    child: Text('场地费', style: TextStyle(fontSize: 12.sp, color: const Color(0xff999999), fontWeight: FontWeight.w500),),
                                  ),                                  
                                ],
                              ),
                            ),


                            const Spacer(),

                            GestureDetector(
                              behavior: HitTestBehavior.translucent,
                              onTap: () {
                                Get.toNamed(AppRoutes.enrollmentDetails, parameters: {
                                  'clubId': '${ clubsController.clubCenterModel?.clubId}',
                                  'matchId': '${ clubsController.clubCenterModel?.clubMatchInfoVOS?[index].matchId}'
                                });
                              },
                              child: Container(
                                decoration: BoxDecoration(
                                  color: const Color(0xffF1F1F1),
                                  borderRadius: BorderRadius.circular(24.r)
                                ),
                                padding: EdgeInsets.symmetric(vertical: 9.w, horizontal: 22.w),
                                child: Text('详情', style: TextStyle(fontSize: 14.sp, color: const Color(0xff499360), fontWeight: FontWeight.w500),),
                              ),
                            ),

                            SizedBox(width: 8.w,),

                            GestureDetector(
                              behavior: HitTestBehavior.translucent,
                              onTap: () {
                                if (item?.isSignUp == true) {
                                  if (item?.isPay == true) {
                                    if (item?.normalCancellation == true) {
                                      // 取消报名
                                      clubsController.cancelSignUp(item?.matchId);
                                    } else {
                                      // 报水
                                      clubsController.cancelSignUp(item?.matchId);
                                    }
                                  } else if (item?.isPay == false) {
                                    /// 去缴费
                                    Get.toNamed(AppRoutes.rechargePayment, parameters: {
                                      'matchId': '${item?.matchId}'
                                    });
                                  }
                                } else {
                                  /// 快速报名
                                  clubsController.signUp(item?.matchId);
                                }
                              },
                              child: Container(
                                decoration: BoxDecoration(
                                  color: bgColor,
                                  borderRadius: BorderRadius.circular(24.r)
                                ),
                                padding: EdgeInsets.symmetric(vertical: 9.w, horizontal: 22.w),
                                child: Text(floatText, style: TextStyle(fontSize: 14.sp, color: Colors.white, fontWeight: FontWeight.w500),),
                              ),
                            ),

                            SizedBox(width: 12.w,),
                          ],
                        ),
                      )
                    ],
                  ),
                ),
              ),

              Positioned(
                right: 1.w,
                top: 16.w,
                child: Container(
                  width: 103.w,
                  height: 40.w,
                  padding: EdgeInsets.only(top: 3.w),
                  decoration: BoxDecoration(
                    image: DecorationImage(
                      fit: BoxFit.fill, 
                      image: AssetImage(clubsController.clubCenterModel?.clubMatchInfoVOS?[index].isFull == true ? 'assets/images/game_gray.png' : 'assets/images/game_flag.png')
                    ),
                  ),
                  child: RichText(
                    textAlign: TextAlign.center,
                    text: TextSpan(text: "已报名",style: TextStyle(color: Colors.white, fontSize: 12.sp),
                      children: [
                        TextSpan(text: " ${clubsController.clubCenterModel?.clubMatchInfoVOS?[index].signUpUserNum ?? 0}",style: TextStyle(
                          color:clubsController.clubCenterModel?.clubMatchInfoVOS?[index].isFull == true ? Colors.red : Colors.white, fontWeight: FontWeight.w600, fontSize: 16.sp),),
                        TextSpan(text: "/${clubsController.clubCenterModel?.clubMatchInfoVOS?[index].matchNumberParticipants ?? 0}",style: TextStyle(color: Colors.white, fontSize: 12.sp),),
                      ]
                    )
                  )
                )
              ),
            ],
          );
        },
        // pagination: const SwiperPagination(
        //   alignment: Alignment.bottomCenter,
        //   margin: EdgeInsets.all(4),
        //   builder: SwiperPointPagination(),
        // ),
        onTap: (index) {
        },
      ),
    );
  }

  /// 动态
  _trendsWidget(ClubsController clubsController) {
    
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8.r)
      ),
      width: double.infinity,
      margin: EdgeInsets.symmetric(horizontal: 17.w),
      padding: EdgeInsets.symmetric(vertical: 10.w, horizontal: 15.w),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          SizedBox(
            child: Text('动态', style: TextStyle(fontSize: 16.sp, fontWeight: FontWeight.w500, color: const Color(0xff222222)),),
          ),

          SizedBox(height: 10.w,),

          clubsController.clubDynamicList.isEmpty ? Container(
            margin: EdgeInsets.only(bottom: 70.w),
            padding: EdgeInsets.only(bottom: 30.w, top: 20.w),
            child: const CustomEmpty(text: '该俱乐部暂无动态',),
          ) : SizedBox(
            child: ListView.separated(
              itemCount: clubsController.clubDynamicList.length,
              padding: EdgeInsets.zero,
              shrinkWrap: true,
              physics: const NeverScrollableScrollPhysics(),
              separatorBuilder: (context, index) {
                return Container(
                  width: double.infinity,
                  height: 0.5.w,
                  margin: EdgeInsets.symmetric(vertical: 10.w),
                  color: const Color(0xffdddddd),
                );
              },
              itemBuilder: (BuildContext context, int index) {
                return SizedBox(
                  child: Row(
                    children: [
                      GestureDetector(
                        behavior: HitTestBehavior.translucent,
                        onTap: () {
                          if (clubsController.clubDynamicList[index].userAvatarUrl != null) {
                            Get.to(
                              ExtendedImageSlideWidget(
                                url: "${clubsController.clubDynamicList[index].userAvatarUrl ?? ''}",
                              ),
                              opaque: false
                            );
                          }
                        },
                        child: Container(
                          width: 36.w,
                          height: 36.w,
                          decoration: BoxDecoration(
                            color: const Color(0xffEDF5F1),
                            borderRadius: BorderRadius.circular(36.r)
                          ),
                          padding: EdgeInsets.all(2.w),
                          child: ClipRRect(
                            borderRadius: BorderRadius.circular(36.r),
                            child: Image.network(clubsController.clubDynamicList[index].userAvatarUrl ?? '', fit: BoxFit.fill,)
                          ),
                        ),
                      ),

                      SizedBox(width: 8.w,),

                      Expanded(
                        child: RichText(
                          maxLines: 1,
                          overflow: TextOverflow.ellipsis,
                          text: TextSpan(
                            children: [
                              TextSpan(
                                text: '${clubsController.clubDynamicList[index].message.toString().split(' ')[0]} ',
                                style: TextStyle(fontSize: 14.sp, color: const Color(0xff499360), fontWeight: FontWeight.w400)
                              ),
                              TextSpan(
                                text: '${
                                  clubsController.clubDynamicList[index].message.toString().split(' ').length == 1 ? 
                                  '' : clubsController.clubDynamicList[index].message.toString().split(' ')[1]} ',
                                style: TextStyle(fontSize: 14.sp, color: const Color(0xff222222), fontWeight: FontWeight.w400, )
                              )
                            ]
                          )
                        ),
                      ),

                      SizedBox(
                        child: Text(clubsController.clubDynamicList[index].messageTime ?? '', style: TextStyle(fontSize: 12.sp, color: const Color(0xff999999)),),
                      )
                    ],
                  ),
                );
              },
            ),
          )
        ],
      ),
    );
  }


  _typeColumnIconTextWidget({
    String text = '',
    String icon = ''
  }) {
    return Container(
      padding: EdgeInsets.symmetric(vertical: 6.w),
      child: Row(
        children: [
          SizedBox(
            width: 16.w,
            height: 16.w,
            child: Image.asset(icon),
          ),
          SizedBox(width: 8.w,),
          SizedBox(
            child: Text(text, style: TextStyle(fontSize: 12.sp, color: const Color(0xff666666)),),
          )
        ],
      ),
    );
  }


  _typeRowIconTextWidget({
    String text = '',
    String icon = ''
  }) {
    return Container(
      padding: EdgeInsets.symmetric(vertical: 4.w),
      child: Row(
        children: [
          SizedBox(
            width: 16.w,
            height: 16.w,
            child: Image.asset(icon),
          ),
          SizedBox(width: 8.w,),
          SizedBox(
            child: Text(text, style: TextStyle(fontSize: 12.sp, color: const Color(0xff666666)),),
          )
        ],
      ),
    );
  }


}